package com.mission.schedule.newAdapter

import android.annotation.SuppressLint
import android.app.Service
import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.graphics.Paint
import android.os.Handler
import android.os.Message
import android.os.Vibrator
import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.RecyclerView
import android.text.Html
import android.text.Spannable
import android.text.SpannableStringBuilder
import android.text.style.BackgroundColorSpan
import android.text.style.ForegroundColorSpan
import android.view.*
import android.widget.*
import com.mission.schedule.CommonDialog.CalenderAddCContentDialog
import com.mission.schedule.CommonDialog.CalenderAddDContentDialog
import com.mission.schedule.R
import com.mission.schedule.activity.CalenderNoteEditActivity
import com.mission.schedule.applcation.App
import com.mission.schedule.bean.CalenderNoteBean
import com.mission.schedule.constants.ShareFile
import com.mission.schedule.entity.CLCategoryTable
import com.mission.schedule.entity.CLRepeatTable
import com.mission.schedule.entity.ScheduleTable
import com.mission.schedule.my160920.bean.LyNewNumBean
import com.mission.schedule.utils.*
import com.mission.schedule.widget.SwipeLinearLayout
import kotlinx.android.synthetic.main.adapter_timeall_item_new0.view.*
import kotlinx.android.synthetic.main.schedule_recycyler_headerview.view.*
import java.util.*
import kotlin.collections.ArrayList

/**
 * Created by liwei on 2018/1/23.
 */
class CalenderAdapter(context: Context, unlist: ArrayList<MutableMap<String, String>>,
                      list: ArrayList<MutableMap<String, String>>, handler: Handler,
                      uncount: Int, todaycount: Int, tomorrowcount: Int, inweekcount: Int,
                      outweekcount: Int, localpath: String, outweekfag: String, width: Int, var windowManager: WindowManager) :
        RecyclerView.Adapter<RecyclerView.ViewHolder>() {

    var context = context
    var list = list

    var unlist = unlist
    var sharedPrefUtil: SharedPrefUtil? = null
    var userid = ""

    val handler: Handler = handler
    var uncount = uncount// 今日待办个数
    var todaycount = todaycount// 今日日程个数
    var tomorrowcount = tomorrowcount// 明天日程个数
    var inweekcount = inweekcount// 一周以内日程个数
    var outweekcount = outweekcount// 一周以外日程个数
    var localpath = localpath// 本地存储的背景
    var outweekfag = outweekfag// 判断一周后展示布局是否显示
    var width = width
    var outweekList = java.util.ArrayList<Map<String, String>>()

    var swipeLinearLayouts = arrayListOf<SwipeLinearLayout>()
    val listBeanList = ArrayList<LyNewNumBean.ListBean>()

    init {
        sharedPrefUtil = SharedPrefUtil(context, ShareFile.USERFILE)
        userid = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.USERID, "")
    }

    private fun setOnclick(positions: Int, map: Map<String, String>, what: Int, type: Int) {
        val message = Message.obtain()
        message.arg1 = positions
        message.arg2 = type
        message.obj = map
        message.what = what
        handler.sendMessage(message)
    }

    override fun getItemViewType(position: Int): Int {
        return when (position) {
            0 -> 0
            list.size + 1 -> 2
            else -> 1
        }
    }

    override fun getItemCount(): Int = list.size + 2
    inner class Holder(view: View) : RecyclerView.ViewHolder(view)
    inner class FooterHolder(view: View) : RecyclerView.ViewHolder(view)
    inner class HeaderHolder(view: View) : RecyclerView.ViewHolder(view)

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
        val view = LayoutInflater.from(context).inflate(R.layout.adapter_timeall_item_new0, parent, false)
        val fview = LayoutInflater.from(context).inflate(R.layout.emptry_foolterview_translate, parent, false)
        val hview = LayoutInflater.from(context).inflate(R.layout.schedule_recycyler_headerview, parent, false)
        return when (viewType) {
            0 -> HeaderHolder(hview)
            1 -> Holder(view)
            else -> FooterHolder(fview)
        }
    }

    fun setNewState(listBean: List<LyNewNumBean.ListBean>) {
        listBeanList.clear()
        listBeanList.addAll(listBean)
        notifyDataSetChanged()
    }

    fun noschHeaderViewAdapter() {
        schHeaderViewAdapter.notifyDataSetChanged()
    }

    fun updateRead(position: Int, type: Int) {
        if (type == 0 || type == 1) {
            list[position][ScheduleTable.schRead] = "0"
            notifyItemRangeChanged(position, list.size, 1)
        } else {
            unlist[position][ScheduleTable.schRead] = "0"
            notifyItemChanged(0, 1)
        }
    }

    fun updateHeader(unlist: ArrayList<MutableMap<String, String>>) {
        this.unlist = unlist
        notifyItemChanged(0, 1)
    }

    open fun deleteCaledner(position: Int,
                            uncount: Int, todaycount: Int, tomorrowcount: Int, inweekcount: Int,
                            outweekcount: Int, localpath: String, outweekfag: String) {
        this.uncount = uncount
        this.todaycount = todaycount
        this.tomorrowcount = tomorrowcount
        this.inweekcount = inweekcount
        this.outweekcount = outweekcount
        this.localpath = localpath
        this.outweekfag = outweekfag

//        list.removeAt(position)
//        notifyDataSetChanged()
        notifyItemRemoved(position)
        notifyItemRangeRemoved(position, list.size)
//        notifyItemRangeChanged(0, list.size, 1)
    }

    open fun addCalender(position: Int, map: Map<String, String>,
                         uncount: Int, todaycount: Int, tomorrowcount: Int, inweekcount: Int,
                         outweekcount: Int, localpath: String, outweekfag: String) {
        this.uncount = uncount
        this.todaycount = todaycount
        this.tomorrowcount = tomorrowcount
        this.inweekcount = inweekcount
        this.outweekcount = outweekcount
        this.localpath = localpath
        this.outweekfag = outweekfag

//        list.add(position, map)
//        notifyDataSetChanged()
//        notifyItemRangeInserted(position, list.size)
        notifyItemRangeChanged(0, list.size, 1)
    }

    open fun updateCalender(position: Int, map: MutableMap<String, String>) {
        list[position] = map
        notifyItemRangeChanged(position, list.size, 1)
    }

    @SuppressLint("SetTextI18n")
    override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
        if (getItemViewType(position) == 1) {
            var mMap = list[holder.adapterPosition - 1]
            swipeLinearLayouts.add(holder.itemView.sch_sl)
            val holder = holder as Holder
            holder.itemView.sch_sl.setOnSwipeListener { thisSll, isholderrizontal ->
                if (!isholderrizontal) {
                    swipeLinearLayouts
                            .forEach { it.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK) }
                } else {
                    swipeLinearLayouts
                            .filter { it != thisSll }
                            .forEach {
                                //划开一个sll， 其他收缩
                                it.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK)
                            }
                }
            }

            val top_ll = holder.itemView.top_ll
            val timeall_ll = holder.itemView.timeall_ll// 标题栏，包含今天，日期，农历等
            val timeall_tv_month = holder.itemView.timeall_tv_month // 日期
            // 如：08-31
            val timeall_tv_week = holder.itemView.timeall_tv_week // 周几
            // 如：周二
            val timeall_tv_daycount = holder.itemView.timeall_tv_daycount // 今天，明天，几天后
            val timeall_rela_right = holder.itemView.timeall_rela_right // 下面整体布局
            val timeall_tv_time = holder.itemView.timeall_tv_time // 时间
            // 如：全天或08：00
            val timeall_tv_shun = holder.itemView.timeall_tv_shun // 顺延
            // 如：顺
            val timeall_tv_lastday = holder.itemView.timeall_tv_lastday // 多少小时后，多少天后
            val timeall_tv_content = holder.itemView.timeall_tv_content // 日程内容
            // TextView timeall_tv_has = holder.getView(R.id.timeall_tv_has); //
            // 标题栏天后
            val personstate_tv = holder.itemView.personstate_tv// 公开状态
            val tv_delete = holder.itemView.tv_delete// 删除
            val tv_more = holder.itemView.ll_more// 更多
            val more_ll = holder.itemView.delete_ll// 侧滑
            val guoqi_img = holder.itemView.guoqi_img// 过期未结束图标，在今天中才显示
            val comename_tv = holder.itemView.comename_tv// 来自谁的日程
            val datebackground_ll = holder.itemView.datebackground_ll// 今天和日期的背景
            val select_cb = holder.itemView.select_cb
            val timeall_tv_nongli = holder.itemView.timeall_tv_nongli// 农历日期显示
            val bottom_month = holder.itemView.bottom_month
            val bottom_week = holder.itemView.bottom_week
            val select_cb_ll = holder.itemView.select_cb_ll
            val outweek_ll = holder.itemView.outweek_ll// 一周以后布局
            val outweekcount_tv = holder.itemView.outweekcount_tv
            val newcome_ll = holder.itemView.newcome_ll
            val newcome_tv = holder.itemView.newcome_tv
            val timeall_after = holder.itemView.timeall_after// 标题栏几天后
            val important_icon = holder.itemView.important_icon
            val new_img = holder.itemView.new_img
            val xcx_tv = holder.itemView.xcx_tv
            var guoqi_tv = holder.itemView.guoqi_tv // 新,更新
            var bottom_nongli = holder.itemView.bottom_nongli
            val daiban_ad = holder.itemView.daiban_ad

            timeall_rela_right.setOnClickListener {
                // 点击详情菜单
                holder.itemView.sch_sl.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK)
                setOnclick(holder.adapterPosition - 1, mMap, 0, 0)
            }
            timeall_rela_right.setOnLongClickListener {
                //                val vib = context.getSystemService(Service.VIBRATOR_SERVICE) as Vibrator
//                val pattern = longArrayOf(1000, 2000)
//                vib.vibrate(pattern, 1)

                holder.itemView.sch_sl.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK)
                setOnclick(holder.adapterPosition - 1, mMap, -1, 0)
                false
            }
            timeall_ll.setOnClickListener {
                setOnclick(holder.adapterPosition - 1, mMap, 4, 0)
            }
            tv_delete.setOnClickListener {
                holder.itemView.sch_sl.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK)
                // 右滑删除
                setOnclick(holder.adapterPosition - 1, mMap, 3, 0)
            }
//            holder.itemView.ll_more.setOnClickListener {
//                holder.itemView.sch_sl.scrollAuto(SwipeLinearLayout.DIRECTION_SHRINK)
//                // 右滑更多
//                setOnclick(holder.adapterPosition - 1, mMap, 7, 0)
//            }
            select_cb_ll.setOnClickListener {
                // 选中表示结束
                if (select_cb.isChecked) {
                    setOnclick(holder.adapterPosition - 1, mMap, 2, 0)
                } else {
                    setOnclick(holder.adapterPosition - 1, mMap, 2, 1)
                }
            }

            select_cb.setOnClickListener {
                // 选中表示结束
                if (select_cb.isChecked) {
                    setOnclick(holder.adapterPosition - 1, mMap, 2, 0)
                } else {
                    setOnclick(holder.adapterPosition - 1, mMap, 2, 1)
                }
            }
            outweek_ll.setOnClickListener {
                setOnclick(holder.adapterPosition - 1, mMap, 5, 0)
                sharedPrefUtil!!.putString(context, ShareFile.USERFILE, ShareFile.OUTWEEKFAG, "1")
                outweekfag = "1"
                outweek_ll.visibility = View.GONE
                outweekcount_tv.visibility = View.GONE
            }

            timeall_rela_right.setOnTouchListener { v, event ->
                if (event.action == MotionEvent.ACTION_DOWN) {
//                Toast.makeText(context, "${timeall_rela_right.measuredHeight}  ${event.y}", Toast.LENGTH_SHORT).show()
                    App.get(context).pointX = event.x
                    App.get(context).pointY = event.y
                    App.get(context).viewH = timeall_rela_right.measuredHeight.toFloat()
                    App.get(context).rawY = event.rawY
                    App.get(context).pointV = v
                }
                false
            }

            daiban_ad.setOnClickListener {
                sharedPrefUtil!!.putBoolean(ShareFile.ISHUN, true).commit()
                val dialog = CalenderAddCContentDialog(context, R.style.dialog_translucent, windowManager)
                dialog.show()
                dialog.callBack = object : CalenderAddCContentDialog.CallBack {
                    override fun save() {
                        val m = Message()
                        m.what = 8
                        handler.sendMessage(m)
                    }

                    override fun full(content: String) {
                    }
                }
            }

            val displayAlarm = mMap[ScheduleTable.schDisplayTime]
            val postpone = mMap[ScheduleTable.schIsPostpone]
            val alarmClockTime = mMap[ScheduleTable.schTime]
            val isEnd = mMap[ScheduleTable.schIsEnd]
            val beforTime = Integer.parseInt(mMap[ScheduleTable.schBeforeTime])
            val important = mMap[ScheduleTable.schIsImportant]

            val calendar = Calendar.getInstance()
            calendar.time = Date()
            var today = DateUtil.formatDateTime(calendar.time)
            calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 1)
            var tomorrow = DateUtil.formatDateTime(calendar.time)
            calendar.set(Calendar.DAY_OF_MONTH, calendar.get(Calendar.DAY_OF_MONTH) + 7)
            var inweek = DateUtil.formatDateTime(calendar.time)

            val schContentschRemark12 = mMap[ScheduleTable.schContent] + (if (mMap[ScheduleTable.schRemark12] == null) "" else mMap[ScheduleTable.schRemark12])

            if (holder.adapterPosition - 1 == 0) {
                try {
                    outweekList = App.getDBcApplication().queryAllSchData(5, 0, 0) as ArrayList<Map<String, String>>
                } catch (e: Exception) {
                    e.printStackTrace()
                }

                outweekcount = if (outweekList != null && outweekList.size > 0) {
                    outweekList.size
                } else {
                    0
                }
                if (list != null && list.size > 0) {
                    var untaskcount = 0
                    var todaytaskcount = 0
                    var tomorrowtaskcount = 0
                    var inweektaskcount = 0
                    for (i in list.indices) {
                        if (list[i][ScheduleTable.schDate] == today.substring(0, 10)) {
                            if ("0" == list[i][ScheduleTable.schDisplayTime] && "1" == list[i][ScheduleTable.schIsPostpone]) {
                                untaskcount += 1
                            } else {
                                todaytaskcount += 1
                            }
                        } else if (list[i][ScheduleTable.schDate] == tomorrow.substring(0, 10)) {
                            tomorrowtaskcount += 1
                        } else if (DateUtil.parseDate(inweek.substring(0, 10))!!
                                        .time >= DateUtil.parseDate(
                                        list[i][ScheduleTable.schDate])!!.time && DateUtil.parseDate(
                                        list[i][ScheduleTable.schDate])!!
                                        .time > DateUtil.parseDate(tomorrow)!!
                                        .time) {
                            inweektaskcount += 1
                        }
                    }
                    uncount = untaskcount
                    todaycount = todaytaskcount
                    tomorrowcount = tomorrowtaskcount
                    inweekcount = inweektaskcount
                }
            }
            val key = mMap[ScheduleTable.schDate]
            val timeKey = mMap[ScheduleTable.schTime]

            val dateStr = DateUtil.parseDateTime(key + " " + timeKey)
            val ymd = key!!.split("-".toRegex()).dropLastWhile { it.isEmpty() }.toTypedArray()

            var clockTime = ""
            var point = ""
            val point2 = ""
            var sequence = ""
            var shunBackKuang = 0
            var colorState = "#2ea9a4"
            var colorState2 = "#2ea9a4"
            var beforeStr = ""

            beforeStr = when (beforTime) {
                0 -> "0"
                5 -> "-5"
                15 -> "-15"
                30 -> "-30"
                60 -> "-1h"
                120 -> "-2h"
                1440 -> "-1d"
                2 * 1440 -> "-2d"
                3 * 1440 -> "-3d"
                5 * 1440 -> "-5d"
                7 * 1440 -> "-1w"
                15 * 1440 -> "-3w"
                else -> "0"
            }

            if ("1" == isEnd) {
                colorState = "#7F7F7F"// "#9f9f9f";
                colorState2 = "#7F7F7F"
                shunBackKuang = R.drawable.tv_kuang_before
            } else {
                colorState = when (key) {
                    today.substring(0, 10) -> "" + context.resources.getColor(R.color.mingtian_color)
                    tomorrow.substring(0, 10) -> "" + context.resources.getColor(R.color.mingtian_color)
                    else -> "" + context.resources.getColor(R.color.mingtian_color)
                }
                colorState2 = colorState
                val date1 = DateUtil.parseDateTime(DateUtil.formatDateTime(Date()))
                if (dateStr!!.time < date1!!.time) {
                    colorState = "" + context.resources.getColor(R.color.bg_red)
                }

                shunBackKuang = R.drawable.tv_kuang_aftertime
            }
            clockTime = if (beforeStr == "0") {
                ("<font color='" + colorState + "' size='5px'>"
                        + alarmClockTime + "</font>")
            } else {
                ("<font color='" + colorState + "' size='5px'>"
                        + alarmClockTime + "(" + beforeStr + ")" + "</font>")
            }
            // 全天
            point = ("<font color='" + colorState2 + "' size='5px'>"
                    + context.getString(R.string.adapter_allday) + "</font>")
            // 顺延
            sequence = "<font color='" + colorState + "'>" + context.getString(R.string.adapter_shun) + "</font>"

            timeall_tv_content.text = if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                schContentschRemark12.substring(2, schContentschRemark12.length)
            else
                schContentschRemark12
            if ("1" == isEnd) {
                timeall_tv_content.setTextColor(Color.parseColor(colorState))
                timeall_tv_time.setTextColor(Color.parseColor(colorState))
                bottom_month.setTextColor(Color.parseColor(colorState))
                bottom_week.setTextColor(Color.parseColor(colorState))
                timeall_tv_content.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG
            } else {
                timeall_tv_time.setTextColor(context.resources.getColor(R.color.mingtian_color))
                bottom_month.setTextColor(context.resources.getColor(R.color.mingtian_color))
                bottom_week.setTextColor(context.resources.getColor(R.color.mingtian_color))
                timeall_tv_content.setTextColor(Color.BLACK)
                timeall_tv_content.paint.flags = 0 or Paint.ANTI_ALIAS_FLAG
            }

            val openState = mMap[ScheduleTable.schOpenState]
            personstate_tv.visibility = View.GONE
            when (openState) {
                "0" -> personstate_tv.text = ""
                "1" -> personstate_tv.text = "公开"
                else -> personstate_tv.text = ""
            }

            if ("0" == mMap[ScheduleTable.schColorType]) {
                personstate_tv.visibility = View.GONE
            } else {
                if ("" != mMap[ScheduleTable.schColorType]) {
                    val tagname = App.getDBcApplication().QueryTagNameData(
                            Integer.parseInt(mMap[ScheduleTable.schColorType]))!![CLCategoryTable.ctgText]
                    if ("未分类" == tagname) {
                        personstate_tv.visibility = View.GONE
                    } else {
                        personstate_tv.visibility = View.VISIBLE
                    }
                    personstate_tv.text = tagname
                }
            }
            var nongli = ""
            if (list.size > 0) {
                if (DateUtil.parseDate(mMap[ScheduleTable.schDate])!!.after(DateUtil.parseDate("2017-12-31"))) {
                    nongli = App.getDBcApplication().queryLunartoSolarList(mMap[ScheduleTable.schDate], 0)["lunarCalendar"].toString()
                }
            }

            val calendar1 = Calendar.getInstance()
            calendar1.time = DateUtil.parseDate(mMap[ScheduleTable.schDate])

            val dateToday = DateUtil.parseDateTime(DateUtil.formatDateTime(Date()))
            val betweem = (dateStr.time - dateToday!!.time) / 1000
            val day = betweem / (24 * 3600)
            val hour = betweem % (24 * 3600) / 3600
            val min = betweem % 3600 / 60
            val afterday = (DateUtil.parseDate(key)!!.time - DateUtil.parseDate(DateUtil.formatDate(Date()))!!.time) / 1000 / (24 * 3600)
//            if (Integer.valueOf(mMap[ScheduleTable.schcRecommendId]) == -2) {
//                comename_tv.visibility = View.VISIBLE
//                comename_tv.text = "来自网页输入"
//                comename_tv.setTextColor(Color.parseColor("#aaaaaa"))
//            }
            if (holder.adapterPosition - 1 == 0) {
                // 当holder.adapterPosition - 1=0，判断今天中是否有待办日程，有就隐藏标题栏，隐藏顺和天后，如果今天没有日程，然后判断明天和之后的
                timeall_ll.visibility = View.VISIBLE
                if (today.substring(0, 10) == key) {
                    timeall_after.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.VISIBLE
                    outweek_ll.visibility = View.GONE
                    outweekcount_tv.visibility = View.GONE
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE
                    if ("0" == displayAlarm && "1" == postpone) {
                        guoqi_img.visibility = View.GONE
                        timeall_ll.visibility = View.GONE
                        timeall_tv_shun.visibility = View.GONE
                        timeall_tv_lastday.visibility = View.GONE
                        bottom_month.visibility = View.GONE
                        bottom_week.visibility = View.GONE
                        timeall_tv_time.text = context.getString(R.string.adapter_untask)
                        timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                        timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                    } else {
                        timeall_ll.visibility = View.VISIBLE
                        timeall_tv_month.visibility = View.GONE
                        timeall_tv_week.visibility = View.VISIBLE
                        timeall_tv_nongli.visibility = View.VISIBLE
                        timeall_tv_nongli.text = nongli
                        bottom_month.visibility = View.GONE
                        bottom_week.visibility = View.GONE
                        // timeall_tv_has.visibility = View.GONE;
                        timeall_tv_daycount.text = context.getString(R.string.adapter_today)
                        timeall_tv_daycount.textSize = 35.0f
                        datebackground_ll.setBackgroundColor(Color.TRANSPARENT)

                        timeall_tv_nongli.visibility = View.GONE
                        timeall_tv_nongli.text = nongli
                        bottom_nongli.visibility = View.VISIBLE
                        bottom_nongli.text = nongli
                        timeall_tv_month.text = ymd[1] + "-" + ymd[2]
                        timeall_tv_week.text = ymd[1] + "-" + ymd[2] + " " + CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))



                        timeall_tv_time.setTextAppearance(context, R.style.text_style_bold)
//                        if ("" != localpath) {
//                            if ("0" == localpath) {
//                                timeall_tv_week.setTextColor(Color.parseColor("#7F7F7F"))
//                                timeall_tv_nongli.setTextColor(Color.parseColor("#7F7F7F"))
//                                timeall_after.setTextColor(Color.parseColor("#7F7F7F"))
//                            } else {
                        timeall_tv_week.setTextColor(Color.WHITE)
                        timeall_tv_nongli.setTextColor(Color.WHITE)
                        timeall_after.setTextColor(Color.WHITE)
//                            }
//                        } else {
                        timeall_tv_week.setTextColor(context.resources.getColor(R.color.white))
                        timeall_tv_nongli.setTextColor(context.resources.getColor(R.color.white))
                        timeall_after.setTextColor(Color.WHITE)
//                        }
                        if (Math.abs(hour) >= 1) {
                            timeall_tv_lastday.text = if (hour > 0) Math.abs(hour).toString() + "小时后" else Math.abs(hour).toString() + "小时前"
                        } else if (DateUtil.parseDateTimeHm(timeKey)!!.time > DateUtil
                                        .parseDateTimeHm(DateUtil.formatDateTimeHm(Date()))!!.time) {
                            if (Math.abs(min) == 0L) {
                                timeall_tv_lastday.text = ""
                            } else {
                                timeall_tv_lastday.text = if (min > 0) Math.abs(min).toString() + "分钟后" else Math.abs(min).toString() + "分钟前"
                            }
                        }
                        if ("0" == displayAlarm) {
                            guoqi_img.visibility = View.GONE
                            timeall_tv_lastday.visibility = View.GONE
                            if ("1" == mMap[ScheduleTable.schIsPostpone]) {
                                timeall_tv_lastday.visibility = View.GONE
                                timeall_ll.visibility = View.GONE
                                timeall_tv_time.text = context.getString(R.string.adapter_untask)
                                timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                                timeall_tv_shun.visibility = View.GONE
                                timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                            } else {
                                timeall_tv_shun.visibility = View.GONE
                                timeall_tv_time.text = Html.fromHtml(point)
                            }
                        } else {
                            if ("1" == mMap[ScheduleTable.schIsPostpone]) {
                                timeall_tv_time.text = Html.fromHtml(clockTime)
                                timeall_tv_shun.visibility = View.VISIBLE
                                timeall_tv_shun.setBackgroundResource(shunBackKuang)
                                timeall_tv_shun.text = Html.fromHtml(sequence)
                            } else {
                                timeall_tv_shun.visibility = View.GONE
                                timeall_tv_time.text = Html.fromHtml(clockTime)
                            }
                            val date1 = DateUtil.parseDateTime(DateUtil.formatDateTime(Date()))
                            if (dateStr.time < date1!!.time) {
                                if ("0" == displayAlarm) {
                                    if ("1" == isEnd) {
                                        guoqi_img.visibility = View.GONE
                                    } else {
                                        guoqi_img.visibility = View.GONE
                                    }
                                    guoqi_img.visibility = View.GONE
                                    timeall_tv_lastday.visibility = View.GONE
                                } else {
                                    if ("1" == isEnd) {
                                        guoqi_img.visibility = View.GONE
                                    } else {
                                        guoqi_img.visibility = View.GONE
                                    }
                                    timeall_tv_lastday.visibility = View.GONE
                                }
                            } else {
                                guoqi_img.visibility = View.GONE
                                if ("0" == displayAlarm) {
                                    timeall_tv_lastday.visibility = View.GONE
                                } else {
                                    timeall_tv_lastday.visibility = View.VISIBLE
                                }
                            }
                        }

                    }
                } else if (tomorrow.substring(0, 10) == key) {
                    timeall_tv_time.setTextAppearance(context, R.style.text_style_bold)
                    timeall_after.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.VISIBLE
                    outweek_ll.visibility = View.GONE
                    outweekcount_tv.visibility = View.GONE
                    guoqi_img.visibility = View.GONE
                    timeall_tv_month.visibility = View.GONE
                    timeall_tv_week.visibility = View.VISIBLE
                    timeall_tv_nongli.visibility = View.VISIBLE
                    timeall_tv_nongli.text = nongli
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE
                    timeall_ll.visibility = View.VISIBLE
                    timeall_tv_daycount.text = context.getString(R.string.adapter_tomorrow)
                    timeall_tv_daycount.textSize = 35.0f
                    timeall_tv_nongli.visibility = View.GONE
                    timeall_tv_nongli.text = nongli
                    bottom_nongli.visibility = View.VISIBLE
                    bottom_nongli.text = nongli
                    timeall_tv_month.text = ymd[1] + "-" + ymd[2]
                    timeall_tv_week.text = ymd[1] + "-" + ymd[2] + " " + CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))

                    timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"))
                    datebackground_ll.setBackgroundColor(Color.TRANSPARENT)
//                    timeall_tv_week.text = CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))
//                    if ("" != localpath) {
//                        if ("0" == localpath) {
//                            timeall_tv_week.setTextColor(Color.parseColor("#7F7F7F"))
//                            timeall_tv_nongli.setTextColor(Color.parseColor("#7F7F7F"))
//                            timeall_after.setTextColor(Color.parseColor("#7F7F7F"))
//                        } else {
//                            timeall_tv_week.setTextColor(Color.WHITE)
//                            timeall_tv_nongli.setTextColor(Color.WHITE)
//                            timeall_after.setTextColor(Color.WHITE)
//                        }
//                    } else {
                    timeall_tv_week.setTextColor(context.resources.getColor(R.color.white))
                    timeall_tv_nongli.setTextColor(context.resources.getColor(R.color.white))
                    timeall_after.setTextColor(Color.WHITE)
//                    }
                    if (Math.abs(day) >= 1) {
                        timeall_tv_lastday.text = if (day > 0) "${day}天后" else "${Math.abs(day)}天前"
                    } else {
                        timeall_tv_lastday.text = if (hour > 0) "${hour}小时后" else "${Math.abs(hour)}小时前"
                    }
                    if ("0" == displayAlarm) {
                        timeall_tv_lastday.visibility = View.VISIBLE
                        if ("1" == postpone) {
                            timeall_tv_lastday.visibility = View.VISIBLE
                            timeall_ll.visibility = View.VISIBLE
                            timeall_tv_time.text = context.getString(R.string.adapter_untask)
                            timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(point)
                        }
                    } else {
                        timeall_tv_lastday.visibility = View.VISIBLE
                        if ("1" == postpone) {
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                            timeall_tv_shun.visibility = View.VISIBLE
                            timeall_tv_shun.setBackgroundResource(shunBackKuang)
                            timeall_tv_shun.text = Html.fromHtml(sequence)
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                        }
                    }
                } else {
                    timeall_tv_time.setTextAppearance(context, R.style.text_style_bold)
                    timeall_tv_lastday.visibility = View.GONE
                    timeall_after.visibility = View.VISIBLE
                    timeall_tv_daycount.visibility = View.GONE
                    outweek_ll.visibility = View.GONE
                    outweekcount_tv.visibility = View.GONE
                    guoqi_img.visibility = View.GONE
                    timeall_ll.visibility = View.VISIBLE
                    timeall_tv_month.visibility = View.VISIBLE
                    timeall_tv_week.visibility = View.VISIBLE
                    timeall_tv_nongli.visibility = View.VISIBLE
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE

                    timeall_tv_daycount.text = context.getString(R.string.adapter_outweek)
                    timeall_tv_month.text = ymd[1] + "-" + ymd[2]
                    timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"))
                    datebackground_ll.setBackgroundResource(R.drawable.bg_tommorowtextview)
                    timeall_tv_week.text = CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))
//                    if ("" != localpath) {
//                        if ("0" == localpath) {
//                            timeall_after.setTextColor(Color.parseColor("#7F7F7F"))
//                            timeall_tv_nongli.setTextColor(Color.parseColor("#7F7F7F"))
//                            timeall_tv_week.setTextColor(Color.parseColor("#7F7F7F"))
//                        } else {
//                            timeall_tv_nongli.setTextColor(Color.WHITE)
//                            timeall_after.setTextColor(Color.WHITE)
//                            timeall_tv_week.setTextColor(context.resources.getColor(R.color.white))
//                        }
//                    } else {
                    timeall_after.setTextColor(Color.WHITE)
                    timeall_tv_nongli.setTextColor(Color.WHITE)
                    timeall_tv_week.setTextColor(context.resources.getColor(R.color.white))
//                    }
                    timeall_after.text = if (afterday > 0) "${afterday}天后" else "${Math.abs(afterday)}天前"
                    bottom_nongli.visibility = View.GONE
                    if ("0" == displayAlarm) {
                        if ("1" == postpone) {
                            timeall_tv_lastday.visibility = View.GONE
                            timeall_ll.visibility = View.GONE
                            timeall_tv_time.text = context.getString(R.string.adapter_untask)
                            timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(point)
                        }
                    } else {
                        if ("1" == postpone) {
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                            timeall_tv_shun.visibility = View.VISIBLE
                            timeall_tv_shun.setBackgroundResource(shunBackKuang)
                            timeall_tv_shun.text = Html.fromHtml(sequence)
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                        }
                    }
                }
            } else if (list[holder.adapterPosition - 1][ScheduleTable.schDate] == list[holder.adapterPosition - 1 - 1][ScheduleTable.schDate]) {
                // 判断当前日期是否为今天，如果是今天，就得区分待办和今天日程
                // 如果不为今天，就按找平时日程处理
                if (today.substring(0, 10) == list[holder.adapterPosition - 1][ScheduleTable.schDate]) {
                    timeall_after.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.VISIBLE
                    outweek_ll.visibility = View.GONE
                    outweekcount_tv.visibility = View.GONE
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE
                    if ("0" == displayAlarm && "1" == postpone) {// &&
                        guoqi_img.visibility = View.GONE
                        timeall_ll.visibility = View.GONE
                        timeall_tv_lastday.visibility = View.GONE
                        timeall_tv_time.text = context.getString(R.string.adapter_untask)
                        timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                        timeall_tv_shun.visibility = View.GONE
                        timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                    } else {
                        if (holder.adapterPosition - 1 == uncount) {
                            timeall_ll.visibility = View.VISIBLE
                        } else {
                            timeall_ll.visibility = View.GONE
                        }
                        timeall_tv_time.setTextAppearance(context, R.style.text_style_bold)
                        timeall_tv_month.visibility = View.GONE
                        timeall_tv_week.visibility = View.VISIBLE
                        timeall_tv_nongli.visibility = View.VISIBLE
                        timeall_tv_nongli.text = nongli
                        timeall_tv_daycount.text = context.resources.getString(R.string.adapter_today)
                        timeall_tv_daycount.textSize = 35.0f
                        timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"))
                        datebackground_ll.setBackgroundColor(Color.TRANSPARENT)
                        timeall_tv_nongli.visibility = View.GONE
                        timeall_tv_nongli.text = nongli
                        bottom_nongli.visibility = View.VISIBLE
                        bottom_nongli.text = nongli
                        timeall_tv_month.text = ymd[1] + "-" + ymd[2]
                        timeall_tv_week.text = ymd[1] + "-" + ymd[2] + " " + CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))
//
//                        if ("" != localpath) {
//                            if ("0" == localpath) {
//                                timeall_tv_week.setTextColor(Color.parseColor("#7F7F7F"))
//                                timeall_tv_nongli.setTextColor(Color.parseColor("#7F7F7F"))
//                                timeall_after.setTextColor(Color.parseColor("#7F7F7F"))
//                            } else {
//                                timeall_tv_week.setTextColor(Color.WHITE)
//                                timeall_tv_nongli.setTextColor(Color.WHITE)
//                                timeall_after.setTextColor(Color.WHITE)
//                            }
//                        } else {
                        timeall_tv_week.setTextColor(context.resources.getColor(R.color.white))
                        timeall_tv_nongli.setTextColor(context.resources.getColor(R.color.white))
                        timeall_after.setTextColor(Color.WHITE)
//                        }
                        if (Math.abs(hour) >= 1) {
                            timeall_tv_lastday.text = if (hour > 0) "${hour}小时后" else "${Math.abs(hour)}小时前"
                        } else if (DateUtil.parseDateTimeHm(timeKey)!!.time > DateUtil
                                        .parseDateTimeHm(DateUtil.formatDateTimeHm(Date()))!!.time) {
                            if (Math.abs(min) == 0L) {
                                timeall_tv_lastday.text = ""
                            } else {
                                timeall_tv_lastday.text = if (min > 0) "${min}分钟后" else "${Math.abs(min)}分钟前"
                            }
                        } else {
                            if (Math.abs(min) == 0L) {
                                timeall_tv_lastday.text = ""
                            } else {
                                timeall_tv_lastday.text = if (min > 0) "${min}分钟后" else "${Math.abs(min)}分钟前"
                            }
                        }
                        if ("0" == displayAlarm) {
                            timeall_tv_lastday.visibility = View.GONE
                            guoqi_img.visibility = View.GONE
                            if ("1" == mMap[ScheduleTable.schIsPostpone]) {
                                timeall_tv_lastday.visibility = View.GONE
                                timeall_ll.visibility = View.GONE
                                timeall_tv_time.text = context.getString(R.string.adapter_untask)
                                timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                                timeall_tv_shun.visibility = View.GONE
                                timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                            } else {
                                timeall_tv_shun.visibility = View.GONE
                                if (isEnd == "1") {
                                    timeall_tv_time.text = Html.fromHtml(point)
                                } else {
                                    timeall_tv_time.text = Html.fromHtml(point)
                                }
                            }
                        } else {
                            if ("1" == mMap[ScheduleTable.schIsPostpone]) {
                                timeall_tv_time.text = Html.fromHtml(clockTime)
                                timeall_tv_shun.visibility = View.VISIBLE
                                timeall_tv_shun.setBackgroundResource(shunBackKuang)
                                timeall_tv_shun.text = Html.fromHtml(sequence)
                            } else {
                                timeall_tv_shun.visibility = View.GONE
                                timeall_tv_time.text = Html.fromHtml(clockTime)
                            }
                            val date1 = DateUtil.parseDateTime(DateUtil.formatDateTime(Date()))
                            if (dateStr.time < date1!!.time) {
                                if ("1" == isEnd) {
                                    guoqi_img.visibility = View.GONE
                                } else {
                                    guoqi_img.visibility = View.GONE
                                }
                                timeall_tv_lastday.visibility = View.GONE
                            } else {
                                guoqi_img.visibility = View.GONE
                                timeall_tv_lastday.visibility = View.VISIBLE
                            }
                        }
                    }
                } else if (tomorrow.substring(0, 10) == mMap[ScheduleTable.schDate]) {
                    timeall_tv_time.setTextAppearance(context, R.style.text_style_bold)
                    timeall_after.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.VISIBLE
                    outweek_ll.visibility = View.GONE
                    outweekcount_tv.visibility = View.GONE
                    guoqi_img.visibility = View.GONE
                    timeall_ll.visibility = View.GONE
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE
                    if (Math.abs(day) >= 1) {
                        timeall_tv_lastday.text = if (afterday > 0) "${day}天后" else "${Math.abs(day)}天前"
                    } else {
                        timeall_tv_lastday.text = if (hour > 0) "${hour}小时后" else "${Math.abs(hour)}小时前"
                    }
                    bottom_nongli.visibility = View.GONE
                    if ("0" == displayAlarm) {
                        timeall_tv_lastday.visibility = View.GONE
                        if ("1" == postpone) {
                            timeall_tv_lastday.visibility = View.GONE
                            timeall_ll.visibility = View.GONE
                            timeall_tv_time.text = context.getString(R.string.adapter_untask)
                            timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(point)
                        }
                    } else {
                        timeall_tv_lastday.visibility = View.VISIBLE
                        if ("1" == postpone) {
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                            timeall_tv_shun.visibility = View.VISIBLE
                            timeall_tv_shun.setBackgroundResource(shunBackKuang)
                            timeall_tv_shun.text = Html.fromHtml(sequence)
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                        }
                    }
                } else {

                    timeall_tv_time.setTextAppearance(context, R.style.text_style_bold)
                    timeall_after.visibility = View.GONE
                    timeall_tv_lastday.visibility = View.GONE
                    outweek_ll.visibility = View.GONE
                    outweekcount_tv.visibility = View.GONE
                    if (list[holder.adapterPosition - 1][ScheduleTable.schDate] == list[holder.adapterPosition - 1 - 1][ScheduleTable.schDate]) {
                        timeall_ll.visibility = View.GONE
                        timeall_tv_month.visibility = View.GONE
                        timeall_tv_week.visibility = View.GONE
                        timeall_tv_nongli.visibility = View.GONE
                    } else {
                        timeall_ll.visibility = View.VISIBLE
                        timeall_tv_month.visibility = View.VISIBLE
                        timeall_tv_week.visibility = View.VISIBLE
                        timeall_tv_nongli.visibility = View.VISIBLE
                    }
                    guoqi_img.visibility = View.GONE
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.GONE
                    timeall_tv_nongli.text = nongli

                    timeall_tv_daycount.text = context.getString(R.string.adapter_outweek)
                    timeall_tv_month.text = ymd[1] + "-" + ymd[2]
                    timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"))
                    datebackground_ll.setBackgroundResource(R.drawable.bg_tommorowtextview)
                    timeall_tv_week.text = CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))
                    if ("" != localpath) {
                        if ("0" == localpath) {
                            bottom_week.setTextColor(Color.parseColor("#7F7F7F"))
                        } else {
                            bottom_week.setTextColor(context.resources.getColor(R.color.mingtian_color))
                        }
                    } else {
                        if ("1" == isEnd) {
                            bottom_week.setTextColor(Color.parseColor("#7F7F7F"))
                        } else {
                            bottom_week.setTextColor(context.resources.getColor(R.color.mingtian_color))
                        }
                    }
                    timeall_after.text = if (afterday > 0) "${afterday}天后" else "${Math.abs(afterday)}天前"
                    bottom_nongli.visibility = View.GONE
                    if ("0" == displayAlarm) {
                        if ("1" == mMap[ScheduleTable.schIsPostpone]) {
                            timeall_tv_lastday.visibility = View.GONE
                            timeall_ll.visibility = View.GONE
                            timeall_tv_time.text = context.getString(R.string.adapter_untask)
                            timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(point)
                        }
                    } else {
                        if ("1" == mMap[ScheduleTable.schIsPostpone]) {
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                            timeall_tv_shun.visibility = View.VISIBLE
                            timeall_tv_shun.setBackgroundResource(shunBackKuang)
                            timeall_tv_shun.text = Html.fromHtml(sequence)
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                        }
                    }
                    // }
                }
            } else {
                if (today.substring(0, 10) == key) {// 今天
                    timeall_after.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.VISIBLE
                    outweek_ll.visibility = View.GONE
                    outweekcount_tv.visibility = View.GONE
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE
                    if ("0" == displayAlarm && "1" == postpone) {
                        timeall_tv_lastday.visibility = View.GONE
                        timeall_ll.visibility = View.VISIBLE
                        timeall_tv_time.text = context.getString(R.string.adapter_untask)
                        timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                        timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                        timeall_tv_shun.visibility = View.GONE
                    } else {
                        timeall_tv_time.setTextAppearance(context, R.style.text_style_bold)
                        timeall_ll.visibility = View.VISIBLE
                        timeall_tv_nongli.text = nongli
                        timeall_tv_daycount.text = context.getString(R.string.adapter_today)
                        timeall_tv_daycount.textSize = 35.0f
                        timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"))
                        datebackground_ll.setBackgroundColor(Color.TRANSPARENT)
                        timeall_tv_nongli.visibility = View.GONE
                        timeall_tv_nongli.text = nongli
                        bottom_nongli.visibility = View.VISIBLE
                        bottom_nongli.text = nongli
                        timeall_tv_month.text = ymd[1] + "-" + ymd[2]
                        timeall_tv_week.text = ymd[1] + "-" + ymd[2] + " " + CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))

//                        if ("" != localpath) {
//                            if ("0" == localpath) {
//                                timeall_tv_week.setTextColor(Color.parseColor("#7F7F7F"))
//                                timeall_tv_nongli.setTextColor(Color.parseColor("#7F7F7F"))
//                                timeall_after.setTextColor(Color.parseColor("#7F7F7F"))
//                            } else {
//                                timeall_tv_week.setTextColor(Color.WHITE)
//                                timeall_tv_nongli.setTextColor(Color.WHITE)
//                                timeall_after.setTextColor(Color.WHITE)
//                            }
//                        } else {
                        timeall_tv_week.setTextColor(Color.WHITE)
                        timeall_tv_nongli.setTextColor(Color.WHITE)
                        timeall_after.setTextColor(Color.WHITE)
//                        }
                        if (Math.abs(hour) >= 1) {
                            timeall_tv_lastday.text = if (hour > 0) "${hour}小时后" else "${Math.abs(hour)}小时前"
                        } else if (DateUtil.parseDateTimeHm(timeKey)!!.time > DateUtil
                                        .parseDateTimeHm(DateUtil.formatDateTimeHm(Date()))!!.time) {
                            if (Math.abs(min) == 0L) {
                                timeall_tv_lastday.text = ""
                            } else {
                                timeall_tv_lastday.text = if (min > 0) "${min}分钟后" else "${Math.abs(min)}分钟前"
                            }
                        } else {
                            if (Math.abs(min) == 0L) {
                                timeall_tv_lastday.text = ""
                            } else {
                                timeall_tv_lastday.text = if (min > 0) "${min}分钟后" else "${Math.abs(min)}分钟前"
                            }
                        }
                        if ("0" == displayAlarm) {
                            timeall_tv_lastday.visibility = View.GONE
                            if ("1" == mMap[ScheduleTable.schIsPostpone]) {
                                timeall_tv_lastday.visibility = View.GONE
                                timeall_ll.visibility = View.VISIBLE
                                timeall_tv_time.text = context.getString(R.string.adapter_untask)
                                timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                                timeall_tv_shun.visibility = View.GONE

                                timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))

                            } else {
                                timeall_tv_shun.visibility = View.GONE
                                timeall_tv_time.text = Html.fromHtml(point)
                            }
                        } else {
                            if ("1" == mMap[ScheduleTable.schIsPostpone]) {
                                timeall_tv_time.text = Html.fromHtml(clockTime)
                                timeall_tv_shun.visibility = View.VISIBLE
                                timeall_tv_shun.setBackgroundResource(shunBackKuang)
                                timeall_tv_shun.text = Html.fromHtml(sequence)
                            } else {
                                timeall_tv_shun.visibility = View.GONE
                                timeall_tv_time.text = Html.fromHtml(clockTime)
                            }
                            val date1 = DateUtil.parseDateTime(DateUtil
                                    .formatDateTime(Date()))
                            if (dateStr.time < date1!!.time) {
                                timeall_tv_lastday.visibility = View.GONE
                                if ("1" == isEnd) {
                                    guoqi_img.visibility = View.GONE
                                } else {
                                    //VISIBLE
                                    guoqi_img.visibility = View.GONE
                                }
                            } else {
                                timeall_tv_lastday.visibility = View.VISIBLE
                                guoqi_img.visibility = View.GONE
                            }
                        }
                    }
                } else if (tomorrow.substring(0, 10).toString() == key) {// 明天
                    timeall_tv_time.setTextAppearance(context,
                            R.style.text_style_bold)
                    timeall_tv_month.visibility = View.GONE
                    timeall_tv_week.visibility = View.VISIBLE
                    timeall_tv_nongli.visibility = View.VISIBLE
                    timeall_after.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.VISIBLE
                    outweek_ll.visibility = View.GONE
                    outweekcount_tv.visibility = View.GONE
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE
                    guoqi_img.visibility = View.GONE
                    timeall_ll.visibility = View.VISIBLE
                    timeall_tv_nongli.text = nongli
                    timeall_tv_daycount.text = context.getString(R.string.adapter_tomorrow)
                    timeall_tv_daycount.textSize = 35.0f
                    timeall_tv_nongli.visibility = View.GONE
                    timeall_tv_nongli.text = nongli
                    bottom_nongli.visibility = View.VISIBLE
                    bottom_nongli.text = nongli
                    timeall_tv_month.text = ymd[1] + "-" + ymd[2]
                    timeall_tv_week.text = ymd[1] + "-" + ymd[2] + " " + CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))

                    timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"))
                    datebackground_ll.setBackgroundColor(Color.TRANSPARENT)
//                    timeall_tv_week.text = CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))
//                    if ("" != localpath) {
//                        if ("0" == localpath) {
//                            timeall_tv_week.setTextColor(Color.parseColor("#7F7F7F"))
//                            timeall_tv_nongli.setTextColor(Color.parseColor("#7F7F7F"))
//                            timeall_after.setTextColor(Color.parseColor("#7F7F7F"))
//                        } else {
//                            timeall_tv_week.setTextColor(Color.WHITE)
//                            timeall_tv_nongli.setTextColor(Color.WHITE)
//                            timeall_after.setTextColor(Color.WHITE)
//                        }
//                    } else {
                    timeall_tv_week.setTextColor(Color.WHITE)
                    timeall_tv_nongli.setTextColor(Color.WHITE)
                    timeall_after.setTextColor(Color.WHITE)
//                    }
                    if (Math.abs(day) >= 1) {
                        timeall_tv_lastday.text = if (afterday > 0) "${day}天后" else "${Math.abs(day)}天前"
                    } else {
                        timeall_tv_lastday.text = if (hour > 0) "${hour}小时后" else "${Math.abs(hour)}小时前"
                    }
                    if ("0" == displayAlarm) {
                        timeall_tv_lastday.visibility = View.GONE
                        if ("1" == postpone) {
                            timeall_tv_lastday.visibility = View.GONE
                            timeall_ll.visibility = View.VISIBLE
                            timeall_tv_time.text = context.getString(R.string.adapter_untask)
                            timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                            timeall_tv_shun.visibility = View.GONE

                            timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(point)
                        }
                    } else {
                        timeall_tv_lastday.visibility = View.VISIBLE
                        if ("1" == postpone) {
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                            timeall_tv_shun.visibility = View.VISIBLE
                            timeall_tv_shun.setBackgroundResource(shunBackKuang)
                            timeall_tv_shun.text = Html.fromHtml(sequence)
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                        }
                    }
                } else {
                    timeall_tv_time.setTextAppearance(context,
                            R.style.text_style_bold)
                    timeall_tv_lastday.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.GONE

                    if (list[holder.adapterPosition - 1][ScheduleTable.schDate] == list[holder.adapterPosition - 1 - 1][ScheduleTable.schDate]) {
                        timeall_ll.visibility = View.GONE
                        timeall_after.visibility = View.GONE
                        timeall_tv_month.visibility = View.GONE
                        timeall_tv_week.visibility = View.GONE
                        timeall_tv_nongli.visibility = View.GONE
                    } else {
                        timeall_ll.visibility = View.VISIBLE
                        timeall_after.visibility = View.VISIBLE
                        timeall_tv_month.visibility = View.VISIBLE
                        timeall_tv_week.visibility = View.VISIBLE
                        timeall_tv_nongli.visibility = View.VISIBLE
                    }
                    timeall_tv_nongli.text = nongli
                    guoqi_img.visibility = View.GONE
                    bottom_month.visibility = View.GONE
                    bottom_week.visibility = View.GONE
                    timeall_tv_daycount.visibility = View.GONE
                    timeall_tv_daycount.text = context.getString(R.string.adapter_outweek)
                    timeall_tv_month.text = ymd[1] + "-" + ymd[2]

                    timeall_tv_daycount.setTextColor(Color.parseColor("#ffffff"))
                    datebackground_ll.setBackgroundResource(R.drawable.bg_tommorowtextview)
                    timeall_tv_week.text = CharacterUtil.getWeekOfDate(context, DateUtil.parseDate(key))
//                    if ("" != localpath) {
//                        if ("0" == localpath) {
////                            timeall_tv_week.setTextColor(Color.parseColor("#7F7F7F"))
////                            timeall_tv_nongli.setTextColor(Color.parseColor("#7F7F7F"))
////                            timeall_after.setTextColor(Color.parseColor("#7F7F7F"))
//                            if ("1" == isEnd) {
//                                bottom_week.setTextColor(Color.parseColor("#7F7F7F"))
//                            } else {
//                                bottom_week.setTextColor(context.resources.getColor(R.color.mingtian_color))
//                            }
//                        } else {
//                            timeall_tv_week.setTextColor(Color.WHITE)
//                            timeall_after.setTextColor(Color.WHITE)
//                            timeall_tv_nongli.setTextColor(Color.WHITE)
//                            if ("1" == isEnd) {
//                                bottom_week.setTextColor(Color.parseColor("#7F7F7F"))
//                            } else {
//                                bottom_week.setTextColor(context.resources.getColor(R.color.mingtian_color))
//                            }
////                        }
//                    } else {
                    timeall_tv_week.setTextColor(Color.WHITE)
                    timeall_tv_nongli.setTextColor(Color.WHITE)
                    timeall_after.setTextColor(Color.WHITE)
                    if ("1" == isEnd) {
                        bottom_week.setTextColor(Color.parseColor("#7F7F7F"))
                    } else {
                        bottom_week.setTextColor(context.resources.getColor(R.color.mingtian_color))
                    }
//                    }
                    if (Math.abs(day) >= 1) {
                        timeall_after.text = if (afterday > 0) "${afterday}天后" else "${Math.abs(afterday)}天前"
                    } else {
                        timeall_after.text = if (hour > 0) "${hour}小时后" else "${Math.abs(hour)}小时前"
                    }
                    bottom_nongli.visibility = View.GONE
                    if ("0" == displayAlarm) {
                        if ("1" == postpone) {
                            timeall_tv_lastday.visibility = View.GONE
                            timeall_ll.visibility = View.VISIBLE
                            timeall_tv_time.text = context.getString(R.string.adapter_untask)
                            timeall_tv_time.setTextAppearance(context, R.style.text_style_normal)
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(point)
                        }
                    } else {
                        if ("1" == postpone) {
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                            timeall_tv_shun.visibility = View.VISIBLE
                            timeall_tv_shun.setBackgroundResource(shunBackKuang)
                            timeall_tv_shun.text = Html.fromHtml(sequence)
                        } else {
                            timeall_tv_shun.visibility = View.GONE
                            timeall_tv_time.text = Html.fromHtml(clockTime)
                        }
                    }
                }
            }
            // if (holder.adapterPosition - 1 != 0) {
            if (uncount == 0 && todaycount == 0 && tomorrowcount == 0 && inweekcount == 0) {
                outweek_ll.visibility = View.GONE
                outweekcount_tv.visibility = View.GONE
            } else {
                if (holder.adapterPosition - 1 == uncount + todaycount + tomorrowcount + inweekcount - 1) {
                    if ("1" == outweekfag) {
                        outweek_ll.visibility = View.GONE
                        outweekcount_tv.visibility = View.GONE
                    } else {
                        if (outweekcount == 0) {
                            outweek_ll.visibility = View.GONE
                            outweekcount_tv.visibility = View.GONE
                        } else {
                            outweek_ll.visibility = View.VISIBLE
                            outweekcount_tv.visibility = View.VISIBLE
                            outweekcount_tv.text = "一周后($outweekcount)"
                        }
                    }
                } else {
                    if ("1" == outweekfag) {
                        outweek_ll.visibility = View.GONE
                        outweekcount_tv.visibility = View.GONE
                    }
                }
            }
            // }
            // 设置时间距离前一个的距离
            val timeparams = LinearLayout.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT)
            if (bottom_month.visibility == View.VISIBLE) {
                timeparams.setMargins(Utils.dipTopx(context, 5f), 0, 0, 0)
                timeall_tv_time.layoutParams = timeparams
            }
            // 设置右边删除
            val params = LinearLayout.LayoutParams(
                    RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.MATCH_PARENT)
            // 设置下面布局
            val params1 = LinearLayout.LayoutParams(
                    RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT)
            // 设置距离顶部距离
            val params2 = LinearLayout.LayoutParams(
                    RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT)

            if (timeall_ll.visibility == View.VISIBLE) {
                if (uncount == 0) {
                    if (position == 0) {
                        params2.setMargins(0, Utils.dipTopx(context, 20f), 0, 0)
                    } else {
                        params2.setMargins(0, Utils.dipTopx(context, 30f), 0, 0)
                    }
                    top_ll.layoutParams = params2
                } else {
                    params2.setMargins(0, Utils.dipTopx(context, 30f), 0, 0)
                    top_ll.layoutParams = params2
                }
            } else {
                params2.setMargins(0, Utils.dipTopx(context, 3f), 0, 0)
                top_ll.layoutParams = params2
            }

//		swipeLayout.setLayoutParams(params1);
            important_icon.visibility = View.GONE
            if ("1" == isEnd) {
                select_cb.isChecked = true
                if ("1" == mMap[ScheduleTable.schIsImportant]) {
                    timeall_rela_right.background = context.resources.getDrawable(R.drawable.bg_sch_end)
                    important_icon.visibility = View.VISIBLE
                    important_icon.background = context.resources.getDrawable(R.mipmap.icon_zhongyao1)
                } else {
                    important_icon.visibility = View.GONE
                    timeall_rela_right.background = context.resources.getDrawable(R.drawable.bg_sch_end)
                }
                comename_tv.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                if ("0" != StringUtils.getIsStringEqulesNull(mMap[ScheduleTable.schcRecommendId])) {
                    if ("" != StringUtils.getIsStringEqulesNull(mMap[ScheduleTable.schcRecommendName]) && StringUtils.getIsStringEqulesNull(mMap[ScheduleTable.schcRecommendName]) != "到期日") {
                        comename_tv.visibility = View.GONE
                        timeall_tv_lastday.visibility = View.GONE
                        if (mMap[ScheduleTable.schSourceDesc]!!.isEmpty()) {
//                            var new_type = false
//                            for (i in listBeanList.indices) {
//                                val cid = listBeanList[i].getCId().trim({ it <= ' ' })
//                                val schid = list[holder.adapterPosition - 1][ScheduleTable.schID]!!.trim({ it <= ' ' })
//                                if (cid == schid && listBeanList[i].getCount() == 1) {
//                                    new_type = true
//                                    break
//                                }
//                            }

                            when {
                                "2" == mMap[ScheduleTable.schRead] -> guoqi_tv.text = "更新"
                                "1" == mMap[ScheduleTable.schRead] -> guoqi_tv.text = "新"
                                else -> guoqi_tv.text = ""
                            }
//                            new_img.background = context.resources.getDrawable(R.mipmap.icon_diandian)
//                            new_img.visibility = if (new_type == true) View.VISIBLE else View.GONE

                            val co = "@" + mMap[ScheduleTable.schcRecommendName] + ":"
                            val cb = co + (if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                                schContentschRemark12.substring(2, schContentschRemark12.length)
                            else
                                schContentschRemark12)
                            val style = SpannableStringBuilder(cb)
                            if (co.isNotEmpty()) {
                                style.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.gongkai_txt)), 0, co.length,
                                        Spannable.SPAN_EXCLUSIVE_INCLUSIVE) //设置指定位置文字的颜色
                            }
                            timeall_tv_content.text = style
                        } else {
//                            if (mMap[ScheduleTable.schRead] == "1" || mMap[ScheduleTable.schRead] == "-1") {
////                                guoqi_img.visibility = View.VISIBLE
//                                guoqi_tv.text = "新"
//                            } else {
//                                guoqi_tv.text = ""
////                                guoqi_img.visibility = View.GONE
//                            }
                            when {
                                "2" == mMap[ScheduleTable.schRead] -> guoqi_tv.text = "更新"
                                "1" == mMap[ScheduleTable.schRead] -> guoqi_tv.text = "新"
                                else -> guoqi_tv.text = ""
                            }
                            var nums = App.getDBcApplication().getCalenderNoteData(mMap[ScheduleTable.schSourceDesc])
                            nums = if (nums != "0" && !nums.isEmpty()) {
                                "($nums)"
                            } else {
                                ""
                            }
                            val co: String
                            var schcRecommen = mMap[ScheduleTable.schTags]
                            timeall_tv_content.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                            timeall_tv_content.text = ""
                            val name = if (mMap[ScheduleTable.schcRecommendId] == userid) "" else "@" + mMap[ScheduleTable.schcRecommendName]
                            if (!schcRecommen!!.isEmpty()) {
                                schcRecommen = if (schcRecommen == name) {
                                    ""
                                } else {
                                    " $schcRecommen"
                                }
                            }
                            if (mMap[ScheduleTable.schcRecommendId] == userid) {
                                schcRecommen = ""
                            }
                            co = name + nums + schcRecommen
                            if (!schContentschRemark12.isEmpty()) {
                                var content1 = schContentschRemark12
                                if (schContentschRemark12.length > 25) {
                                    content1 = schContentschRemark12.substring(0, 25)
                                }
                                content1 = if (content1!!.length > 2 && content1!!.substring(0, 2) == "#%")
                                    content1!!.substring(2, content1!!.length)
                                else
                                    content1
                                val content = if (mMap[ScheduleTable.schcRecommendId] == userid) "#$content1#" else "#$content1"
                                val style = SpannableStringBuilder(content)
                                if (content.isNotEmpty()) {
                                    style.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.blue)), 0, content.length,
                                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) //设置指定位置文字的颜色
                                }

                                timeall_tv_content.append(style)

                                val style1 = SpannableStringBuilder(co)
                                if (co.isNotEmpty()) {
                                    style1.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.gongkai_txt)), 0, co.length,
                                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) //设置指定位置文字的颜色
                                }

                                timeall_tv_content.append(style1)
                            }
                        }

                        if ("1" == isEnd) {
                            val style = SpannableStringBuilder(timeall_tv_content.text.toString())
                            style.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.endtextcolor)), 0, timeall_tv_content.text.toString().length,
                                    Spannable.SPAN_EXCLUSIVE_INCLUSIVE) //设置指定位置文字的颜色
                            timeall_tv_content.text = style
                        }
                    } else {
                        if ("0" != mMap[ScheduleTable.schRepeatID]) {
                            val type = App.getDBcApplication().queryRepateType(mMap[ScheduleTable.schRepeatID])["type"]
                            if ("0" == mMap[ScheduleTable.schRepeatLink]) {
                                comename_tv.visibility = View.GONE
                            } else {
                                comename_tv.visibility = View.VISIBLE
//                                new_img.visibility = View.GONE
                            }
                            comename_tv.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                            val repeatDate = if (mMap[ScheduleTable.schRepeatDate]!!.length > 10)
                                mMap[ScheduleTable.schRepeatDate]!!.substring(5, 10)
                            else
                                ""
                            if ("1" == type) {
                                comename_tv.text = "每天重复 $repeatDate"
                                color = "0"
                            } else if ("2" == type) {
                                comename_tv.text = "每周重复 $repeatDate"
                                color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.WEEKCOLOR1, "4")
                            } else if ("3" == type) {
                                comename_tv.text = "每月重复 $repeatDate"
                                color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.MONTHCOLOR2, "3")
                            } else if ("4" == type || "6" == type) {
                                comename_tv.text = "每年重复 $repeatDate"
                                color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.YEARCOLOR3, "2")
                            } else if ("5" == type) {
                                comename_tv.text = "工作日重复 $repeatDate"
                                color = "0"
                            } else {
                                App.getDBcApplication().deleteScheduleData(mMap[ScheduleTable.schID])
                            }
                            if ("1" == important) {
                                important_icon.visibility = View.VISIBLE
                                important_icon.background = context.resources.getDrawable(R.mipmap.icon_zhongyao1)
                            } else {
                                important_icon.visibility = View.GONE
                            }
                        } else {
                            comename_tv.visibility = View.GONE
                        }
                    }
                } else if ("0" != mMap[ScheduleTable.schRepeatID]) {
                    val type = App.getDBcApplication().queryRepateType(mMap[ScheduleTable.schRepeatID])["type"]
                    if ("0" == mMap[ScheduleTable.schRepeatLink]) {
                        comename_tv.visibility = View.GONE
                    } else {
                        comename_tv.visibility = View.VISIBLE
//                        new_img.visibility = View.GONE
                    }
                    val repeatDate = if (mMap[ScheduleTable.schRepeatDate]!!.length > 10)
                        mMap[ScheduleTable.schRepeatDate]!!.substring(5, 10)
                    else
                        ""
                    if ("1" == type) {
                        comename_tv.text = "每天重复 $repeatDate"
                        color = "0"
                    } else if ("2" == type) {
                        comename_tv.text = "每周重复 $repeatDate"
                        color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.WEEKCOLOR1, "4")
                    } else if ("3" == type) {
                        comename_tv.text = "每月重复 $repeatDate"
                        color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.MONTHCOLOR2, "3")
                    } else if ("4" == type || "6" == type) {
                        comename_tv.text = "每年重复 $repeatDate"
                        color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.YEARCOLOR3, "2")
                    } else if ("5" == type) {
                        comename_tv.text = "工作日重复 $repeatDate"
                        color = "0"
                    } else {
                        App.getDBcApplication().deleteScheduleData(mMap[ScheduleTable.schID])
                    }
                    if ("1" == important) {
                        important_icon.visibility = View.VISIBLE
                        important_icon.background = context.resources.getDrawable(R.mipmap.icon_zhongyao1)
                    } else {
                        important_icon.visibility = View.GONE
                    }
                }
                if ("2" == mMap[ScheduleTable.schSourceType]) {
                    timeall_tv_content.text = if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                        schContentschRemark12.substring(2, schContentschRemark12.length)
                    else
                        schContentschRemark12
                    val list = App.getDBcApplication().getCalenderNoteDetailData(userid, mMap[ScheduleTable.schSourceDesc], false)

                    val nums: String

                    if (list.size > 0) {
                        nums = when {
                            list[0].style == 0 -> {
                                val endstate = list.count { it.endstate == 1 }
                                "(" + endstate + "/" + list.size + ")"
                            }
                            list[0].style == 4 -> "(" + nums(list[0].style, list) + ")"
                            else -> "(" + list.size + ")"
                        }

                        val style1 = SpannableStringBuilder(nums)
                        if (nums.isNotEmpty()) {
                            style1.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.gongkai_txt)), 0, nums.length,
                                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) //设置指定位置文字的颜色
                        }

                        timeall_tv_content.append(style1)

                        if ("1" == isEnd) {
                            val style = SpannableStringBuilder(timeall_tv_content.text)
                            style.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.endtextcolor)), 0, timeall_tv_content.text.length,
                                    Spannable.SPAN_EXCLUSIVE_INCLUSIVE) //设置指定位置文字的颜色
                            timeall_tv_content.text = style
                        }
                    }
                } else if ("3" == mMap[ScheduleTable.schSourceType] || "4" == mMap[ScheduleTable.schSourceType] || "5" == mMap[ScheduleTable.schSourceType]) {
                    timeall_tv_content.text = if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                        schContentschRemark12.substring(2, schContentschRemark12.length)
                    else
                        schContentschRemark12
                    if ("3" == mMap[ScheduleTable.schSourceType]) {
                        timeall_tv_content.setTextColor(context.resources.getColor(R.color.Saturdaybackcolor))
                    } else {
                        timeall_tv_content.setTextColor(context.resources.getColor(R.color.blue))
                    }
                    var nums = App.getDBcApplication().getCalenderNoteData(mMap[ScheduleTable.schSourceDesc])
                    nums = if (nums != "0" && !nums.isEmpty()) {
                        "($nums)"
                    } else {
                        ""
                    }
                    val style1 = SpannableStringBuilder(nums)
                    if (nums.isNotEmpty()) {
                        style1.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.gongkai_txt)), 0, nums.length,
                                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) //设置指定位置文字的颜色
                    }
                    timeall_tv_content.append(style1)
                    if (mMap[ScheduleTable.schcRecommendName]!!.isNotEmpty() && mMap[ScheduleTable.schcRecommendId]!!.isNotEmpty()) {
                        comename_tv.visibility = View.VISIBLE
                        comename_tv.text = "@" + mMap[ScheduleTable.schcRecommendName]
                    }
                    comename_tv.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                    if (isEnd == "1") {
                        timeall_tv_content.setTextColor(Color.parseColor(colorState))
                        timeall_tv_time.setTextColor(Color.parseColor(colorState))
                        bottom_month.setTextColor(Color.parseColor(colorState))
                        bottom_week.setTextColor(Color.parseColor(colorState))
                        timeall_tv_content.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG
                    }
                }

                if (Integer.valueOf(mMap[ScheduleTable.schcRecommendId]) < 0 && mMap[ScheduleTable.schcRecommendName]!!.isEmpty()) {
                    comename_tv.visibility = View.VISIBLE
                    comename_tv.text = "到期日"
                }
//                if (Integer.valueOf(mMap[ScheduleTable.schcRecommendId]) == -2) {
//                    comename_tv.visibility = View.VISIBLE
//                    comename_tv.text = "来自网页输入"
//                    comename_tv.setTextColor(Color.parseColor("#aaaaaa"))
//                }
            } else {
                if ("1" == important) {
                    important_icon.visibility = View.VISIBLE
                    important_icon.background = context.resources.getDrawable(R.mipmap.icon_zhongyao)
                } else {
                    important_icon.visibility = View.GONE
                }
                timeall_rela_right.background = context.resources.getDrawable(R.drawable.bg_sch_normal)
                select_cb.isChecked = false

                if ("0" != StringUtils.getIsStringEqulesNull(mMap[ScheduleTable.schcRecommendId])) {
                    if ("" != StringUtils.getIsStringEqulesNull(mMap[ScheduleTable.schcRecommendName]) && StringUtils.getIsStringEqulesNull(mMap[ScheduleTable.schcRecommendName]) != "到期日") {
                        comename_tv.visibility = View.GONE
                        timeall_tv_lastday.visibility = View.GONE
                        if (mMap[ScheduleTable.schSourceDesc]!!.isEmpty()) {
                            var new_type = false
                            for (i in listBeanList.indices) {
                                val cid = listBeanList[i].getCId().trim { it <= ' ' }
                                val schid = list[holder.adapterPosition - 1][ScheduleTable.schID]!!.trim { it <= ' ' }
                                if (cid == schid && listBeanList[i].getCount() == 1) {
                                    new_type = true
                                    break
                                }
                            }

                            when {
                                "2" == mMap[ScheduleTable.schRead] -> guoqi_tv.text = "更新"
                                "1" == mMap[ScheduleTable.schRead] -> guoqi_tv.text = "新"
                                else -> guoqi_tv.text = ""
                            }
//                            new_img.background = context.resources.getDrawable(R.mipmap.icon_diandian)
//                            new_img.visibility = if (new_type == true) View.VISIBLE else View.GONE
                            val co = "@" + mMap[ScheduleTable.schcRecommendName] + ":"
                            val cb = co + (if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                                schContentschRemark12.substring(2, schContentschRemark12.length)
                            else
                                schContentschRemark12)
                            val style = SpannableStringBuilder(cb)
                            if (co.isNotEmpty()) {
                                style.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.mingtian_color)), 0, co.length,
                                        Spannable.SPAN_EXCLUSIVE_INCLUSIVE) //设置指定位置文字的颜色
                            }
                            timeall_tv_content.text = style
                        } else {
//                            if (mMap[ScheduleTable.schRead] == "1" || mMap[ScheduleTable.schRead] == "-1") {
////                                guoqi_img.visibility = View.VISIBLE
//                                guoqi_tv.text = "新"
//                            } else {
//                                guoqi_tv.text = ""
////                                guoqi_img.visibility = View.GONE
//                            }
                            when {
                                "2" == mMap[ScheduleTable.schRead] -> guoqi_tv.text = "更新"
                                "1" == mMap[ScheduleTable.schRead] -> guoqi_tv.text = "新"
                                else -> guoqi_tv.text = ""
                            }
                            var nums = App.getDBcApplication().getCalenderNoteData(mMap[ScheduleTable.schSourceDesc])
                            nums = if (nums != "0" && !nums.isEmpty()) {
                                "($nums)"
                            } else {
                                ""
                            }
                            val co: String
                            var schcRecommen = mMap[ScheduleTable.schTags]
                            timeall_tv_content.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                            timeall_tv_content.text = ""
                            val name = if (mMap[ScheduleTable.schcRecommendId] == userid) "" else "@" + mMap[ScheduleTable.schcRecommendName]
                            if (!schcRecommen!!.isEmpty()) {
                                schcRecommen = if (schcRecommen == name) {
                                    ""
                                } else {
                                    " $schcRecommen"
                                }
                            }
                            if (mMap[ScheduleTable.schcRecommendId] == userid) {
                                schcRecommen = ""
                            }
                            co = name + nums + schcRecommen
                            if (!schContentschRemark12.isEmpty()) {
                                var content1 = schContentschRemark12
                                if (schContentschRemark12.length > 25) {
                                    content1 = schContentschRemark12.substring(0, 25)
                                }
                                content1 = if (content1!!.length > 2 && content1!!.substring(0, 2) == "#%")
                                    content1!!.substring(2, content1!!.length)
                                else
                                    content1
                                val content = if (mMap[ScheduleTable.schcRecommendId] == userid) "#$content1#" else "#$content1"
                                val style = SpannableStringBuilder(content)
                                if (content.isNotEmpty()) {
                                    style.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.blue)), 0, content.length,
                                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) //设置指定位置文字的颜色
                                }
                                timeall_tv_content.append(style)

                                val style1 = SpannableStringBuilder(co)
                                if (co.isNotEmpty()) {
                                    style1.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.gongkai_txt)), 0, co.length,
                                            Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) //设置指定位置文字的颜色
                                }
                                timeall_tv_content.append(style1)
                            }
                        }

                        if ("1" == isEnd) {
                            val style = SpannableStringBuilder(timeall_tv_content.getText().toString())
                            style.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.endtextcolor)), 0, timeall_tv_content.getText().toString().length,
                                    Spannable.SPAN_EXCLUSIVE_INCLUSIVE) //设置指定位置文字的颜色
                            timeall_tv_content.text = style
                        }

                    } else {
                        if ("0" != mMap[ScheduleTable.schRepeatID]) {
                            val type = App.getDBcApplication().queryRepateType(
                                    mMap[ScheduleTable.schRepeatID])["type"]
                            if ("0" == mMap[ScheduleTable.schRepeatLink]) {
                                comename_tv.visibility = View.GONE
                            } else {
                                comename_tv.visibility = View.VISIBLE
//                                new_img.visibility = View.GONE
                            }
                            comename_tv.setTextColor(context.resources
                                    .getColor(R.color.gongkai_txt))
                            val repeatDate = if (mMap[ScheduleTable.schRepeatDate]!!.length > 10)
                                mMap[ScheduleTable.schRepeatDate]!!.substring(5, 10)
                            else
                                ""
                            if ("1" == type) {
                                comename_tv.text = "每天重复 " + repeatDate
                                color = "0"
                            } else if ("2" == type) {
                                comename_tv.text = "每周重复 " + repeatDate
                                color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.WEEKCOLOR1, "4")
                            } else if ("3" == type) {
                                comename_tv.text = "每月重复 " + repeatDate
                                color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.MONTHCOLOR2, "3")
                            } else if ("4" == type || "6" == type) {
                                comename_tv.text = "每年重复 " + repeatDate
                                color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.YEARCOLOR3, "2")
                            } else if ("5" == type) {
                                comename_tv.text = "工作日重复 " + repeatDate
                                color = "0"
                            } else {
                                App.getDBcApplication().deleteScheduleData(mMap[ScheduleTable.schID])
                            }
                            setBGcolor(timeall_rela_right, color)
                        } else {
                            comename_tv.visibility = View.GONE
                        }
                    }
                } else {
                    if ("0" != mMap[ScheduleTable.schRepeatID]) {
                        val type = App
                                .getDBcApplication()
                                .queryRepateType(mMap[ScheduleTable.schRepeatID])["type"]
                        if ("0" == mMap[ScheduleTable.schRepeatLink]) {
                            comename_tv.visibility = View.GONE
                        } else {
                            comename_tv.visibility = View.VISIBLE
//                            new_img.visibility = View.GONE
                        }
                        comename_tv.setTextColor(context.resources.getColor(R.color.gongkai_txt))
                        val repeatDate = if (mMap[ScheduleTable.schRepeatDate]!!.length > 10)
                            mMap[ScheduleTable.schRepeatDate]!!.substring(5, 10)
                        else
                            ""
                        if ("1" == type) {
                            comename_tv.text = "每天重复 " + repeatDate
                            color = "0"
                        } else if ("2" == type) {
                            comename_tv.text = "每周重复 " + repeatDate
                            color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.WEEKCOLOR1, "4")
                        } else if ("3" == type) {
                            comename_tv.text = "每月重复 " + repeatDate
                            color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.MONTHCOLOR2, "3")
                        } else if ("4" == type || "6" == type) {
                            comename_tv.text = "每年重复 " + repeatDate
                            color = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.YEARCOLOR3, "2")
                        } else if ("5" == type) {
                            comename_tv.text = "工作日重复 " + repeatDate
                            color = "0"
                        } else {
                            App.getDBcApplication().deleteScheduleData(mMap[ScheduleTable.schID])
                        }
                        if ("1" == important) {
                            important_icon.visibility = View.VISIBLE
                            important_icon.background = context.resources.getDrawable(R.mipmap.icon_zhongyao)
                        } else {
                            important_icon.visibility = View.GONE
                        }
                        setBGcolor(timeall_rela_right, color)
                    } else {
                        comename_tv.visibility = View.GONE
                    }
                }

                if ("2" == mMap[ScheduleTable.schSourceType]) {
                    timeall_tv_content.text = if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                        schContentschRemark12.substring(2, schContentschRemark12.length)
                    else
                        schContentschRemark12
                    val list = App.getDBcApplication().getCalenderNoteDetailData(userid, mMap[ScheduleTable.schSourceDesc], false)

                    val nums: String

                    if (list.size > 0) {
                        nums = when {
                            list[0].style == 0 -> {
                                val endstate = list.count { it.endstate == 1 }
                                "(" + endstate + "/" + list.size + ")"
                            }
                            list[0].style == 4 -> "(" + nums(list[0].style, list) + ")"
                            else -> "(" + list.size + ")"
                        }

                        val style1 = SpannableStringBuilder(nums)
                        if (nums.isNotEmpty()) {
                            style1.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.gongkai_txt)), 0, nums.length,
                                    Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) //设置指定位置文字的颜色
                        }
                        val map = App.getDBcApplication().QueryhongFuData(mMap[ScheduleTable.schRepeatID])
                        if (map != null) {
                            if (map[CLRepeatTable.repContent]!!.length > 2 && map[CLRepeatTable.repContent]!!.substring(0, 2) == "#%") {
                                val list1 = App.getDBcApplication().getCalenderNoteDetailData(userid, map[CLRepeatTable.repSourceDesc], false)
                                if (list1.size >= 1 && UriUtils.isUrl(list1[0].contents)) {
                                    xcx_tv.visibility = View.VISIBLE
                                } else {
                                    timeall_tv_content.append(style1)
                                }
                            } else {
                                timeall_tv_content.append(style1)
                            }
                        } else if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%") run {
                            val list = App.getDBcApplication().getCalenderNoteDetailData(userid, mMap[ScheduleTable.schSourceDesc], false)
                            if (list.size >= 1 && UriUtils.isUrl(list[0].contents)) {
                                xcx_tv.visibility = View.VISIBLE
                            } else {
                                timeall_tv_content.append(style1)
                            }
                        } else {
                            timeall_tv_content.append(style1)
                        }

                        if ("1" == isEnd) {
                            val style = SpannableStringBuilder(timeall_tv_content.text.toString())
                            style.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.endtextcolor)), 0, timeall_tv_content.text.length,
                                    Spannable.SPAN_EXCLUSIVE_INCLUSIVE) //设置指定位置文字的颜色
                            timeall_tv_content.text = style
                        }
                    }
                } else if ("3" == mMap[ScheduleTable.schSourceType] || "4" == mMap[ScheduleTable.schSourceType] || "5" == mMap[ScheduleTable.schSourceType]) {
                    timeall_tv_content.text = if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                        schContentschRemark12.substring(2, schContentschRemark12.length)
                    else
                        schContentschRemark12
                    if ("3" == mMap[ScheduleTable.schSourceType]) {
                        timeall_tv_content.setTextColor(context.resources.getColor(R.color.Saturdaybackcolor))
                    } else {
                        timeall_tv_content.setTextColor(context.resources.getColor(R.color.blue))
                    }

                    var nums = App.getDBcApplication().getCalenderNoteData(mMap[ScheduleTable.schSourceDesc])
                    nums = if (nums != "0" && !nums.isEmpty()) {
                        "($nums)"
                    } else {
                        ""
                    }
                    val style1 = SpannableStringBuilder(nums)
                    if (nums.isNotEmpty()) {
                        style1.setSpan(ForegroundColorSpan(context.resources.getColor(R.color.gongkai_txt)), 0, nums.length,
                                Spannable.SPAN_EXCLUSIVE_EXCLUSIVE) //设置指定位置文字的颜色
                    }
                    timeall_tv_content.append(style1)
                    if (mMap[ScheduleTable.schcRecommendName]!!.isNotEmpty() && mMap[ScheduleTable.schcRecommendId]!!.isNotEmpty()) {
                        comename_tv.visibility = View.VISIBLE
                        comename_tv.text = "@" + mMap[ScheduleTable.schcRecommendName]
                    }
                    comename_tv.setTextColor(context.resources.getColor(R.color.gongkai_txt))

                    if (isEnd == "1") {
                        timeall_tv_content.setTextColor(Color.parseColor(colorState))
                        timeall_tv_time.setTextColor(Color.parseColor(colorState))
                        bottom_month.setTextColor(Color.parseColor(colorState))
                        bottom_week.setTextColor(Color.parseColor(colorState))
                        timeall_tv_content.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG
                    }
                }
                if (Integer.valueOf(mMap[ScheduleTable.schcRecommendId]) < 0 && mMap[ScheduleTable.schcRecommendName]!!.isEmpty()) {
                    comename_tv.visibility = View.VISIBLE
                    comename_tv.text = "到期日"
                }
//                if (Integer.valueOf(mMap[ScheduleTable.schcRecommendId]) == -2) {
//                    comename_tv.visibility = View.VISIBLE
//                    comename_tv.text = "来自网页输入"
//                    comename_tv.setTextColor(Color.parseColor("#aaaaaa"))
//                }
            }

            if ("3" == isEnd && ("1" == mMap[ScheduleTable.schRead] || "2" == mMap[ScheduleTable.schRead])) {
                if (Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schcRecommendId]) > 0 && Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schAID]) == 0) {
//                    new_img.background = context.resources.getDrawable(R.mipmap.icon_diandian)
//                    new_img.visibility = View.VISIBLE
                    timeall_tv_lastday.visibility = View.GONE
                    guoqi_img.visibility = View.GONE
                    guoqi_tv.text = "新"
                    newcome_ll.visibility = View.GONE
                    comename_tv.visibility = View.GONE
                    if ("2" == mMap[ScheduleTable.schRead]) {
                        guoqi_tv.text = "更新"
                    }
                }
            } else if ("0" == isEnd && ("1" == mMap[ScheduleTable.schRead] || "2" == mMap[ScheduleTable.schRead])) {
                if (Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schcRecommendId]) > 0 && Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schAID]) == 0) {
                    timeall_tv_lastday.visibility = View.GONE
//                    guoqi_img.visibility = View.VISIBLE
                    guoqi_tv.text = "新"
                    newcome_ll.visibility = View.GONE
                    comename_tv.visibility = View.GONE
                    if ("2" == mMap[ScheduleTable.schRead]) {
                        guoqi_tv.text = "更新"
                    }
                }
            } else if ("2" == isEnd && ("1" == mMap[ScheduleTable.schRead] || "2" == mMap[ScheduleTable.schRead])) {
                if (Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schcRecommendId]) > 0 && Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schAID]) == 0) {
//                    new_img.background = context.resources.getDrawable(R.mipmap.icon_diandian)
//                    new_img.visibility = View.VISIBLE
                    timeall_tv_lastday.visibility = View.GONE
//                    guoqi_img.visibility = View.GONE
                    guoqi_tv.text = "新"
                    newcome_ll.visibility = View.GONE
                    comename_tv.visibility = View.GONE
                    if ("2" == mMap[ScheduleTable.schRead]) {
                        guoqi_tv.text = "更新"
                    }
                }
            } else {
//                if (Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schcRecommendId]) <= 0 && Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schAID]) != 0) {
//                    new_img.visibility = View.GONE
//                }
                newcome_ll.visibility = View.GONE
                newcome_tv.visibility = View.GONE
                guoqi_tv.text = ""
            }

            if (Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schpisEnd]) == 1 && Integer.valueOf(list[holder.adapterPosition - 1][ScheduleTable.schcRecommendId]) != 0) {
                timeall_tv_content.setTextColor(Color.parseColor("#7F7F7F"))
                timeall_tv_time.setTextColor(Color.parseColor("#7F7F7F"))
                bottom_month.setTextColor(Color.parseColor("#7F7F7F"))
                bottom_week.setTextColor(Color.parseColor("#7F7F7F"))
                select_cb.isChecked = true
                timeall_rela_right.background = context.resources.getDrawable(R.drawable.bg_sch_end)
                timeall_tv_content.paint.flags = Paint.STRIKE_THRU_TEXT_FLAG or Paint.ANTI_ALIAS_FLAG
            }

            if (mMap[ScheduleTable.schcRecommendName]!!.isNotEmpty() && mMap[ScheduleTable.schcRecommendId]!!.isNotEmpty()) {
                comename_tv.visibility = View.VISIBLE
                comename_tv.text = "@" + mMap[ScheduleTable.schcRecommendName]
            }

            xcx_tv.visibility = View.GONE
            if ("0" != list[holder.adapterPosition - 1][ScheduleTable.schRepeatID]) {
                val map = App.getDBcApplication().QueryhongFuData(list[holder.adapterPosition - 1][ScheduleTable.schRepeatID])
                if (map != null) {
                    val bean = App.getDBcApplication().get_tb_function_my(map[CLRepeatTable.remark2])
                    if (bean != null && bean.url.isNotEmpty()) {
                        xcx_tv.visibility = View.VISIBLE
                    } else if (map[CLRepeatTable.repContent]!!.length > 2 && map[CLRepeatTable.repContent]!!.substring(0, 2) == "#%") run {
                        val list = App.getDBcApplication().getCalenderNoteDetailData(userid, map[CLRepeatTable.repSourceDesc], false)
                        if (list.size >= 1 && UriUtils.isUrl(list[0].contents)) {
                            xcx_tv.visibility = View.VISIBLE
                        }
                    } else {
                        xcx_tv.visibility = View.GONE
                    }
                }
            } else if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%") run {
                val list = App.getDBcApplication().getCalenderNoteDetailData(userid, mMap[ScheduleTable.schSourceDesc], false)
                if (list.size >= 1 && UriUtils.isUrl(list[0].contents)) {
                    xcx_tv.visibility = View.VISIBLE
                } else {
                    xcx_tv.visibility = View.GONE
                }
            } else {
                if ("" != mMap[ScheduleTable.schRemark6]) {
                    val bean = App.getDBcApplication().get_tb_function_my(mMap[ScheduleTable.schRemark6])
                    if (bean != null && bean.url.isNotEmpty()) {
                        xcx_tv.visibility = View.VISIBLE
                    } else {
                        xcx_tv.visibility = View.GONE
                    }
                }
            }
            if (isEnd != "1") {
                val style = SpannableStringBuilder(if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                    schContentschRemark12.substring(2, schContentschRemark12.length)
                else
                    schContentschRemark12)
                var remark11 = list[holder.adapterPosition - 1][ScheduleTable.schRemark11]
                if (remark11 == "" || remark11 == null) {
                    remark11 = "0"
                }
                val color = Integer.valueOf(remark11)
                if (color > 0) {
                    style.setSpan(BackgroundColorSpan(context.resources.getColor(colorss[color])), 0, (if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                        schContentschRemark12.substring(2, schContentschRemark12.length)
                    else
                        schContentschRemark12)!!.length,
                            Spannable.SPAN_EXCLUSIVE_INCLUSIVE)
                    if (color > 2) {
                        style.setSpan(ForegroundColorSpan(Color.WHITE), 0, (if (schContentschRemark12.length > 2 && schContentschRemark12.substring(0, 2) == "#%")
                            schContentschRemark12.substring(2, schContentschRemark12.length)
                        else
                            schContentschRemark12)!!.length,
                                Spannable.SPAN_EXCLUSIVE_INCLUSIVE)
                    }
                    timeall_tv_content.text = style
                    timeall_tv_content.setLineSpacing(1f, 1f)
                }

            }
            val TYPEINDEX = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.TYPEINDEX, "3")
            val newopeartType = Integer.valueOf(TYPEINDEX)
            if (newopeartType < 0) {
                timeall_after.setTextColor(Color.WHITE)
                timeall_tv_nongli.setTextColor(Color.WHITE)
                timeall_tv_week.setTextColor(Color.WHITE)
            }
            if (sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.TYPEUID, "").isNotEmpty()) {
                holder.itemView.sch_sl.setScroll(false)
                select_cb.isClickable = false
            } else {
                select_cb.isClickable = true
            }

            if ("1" == mMap[ScheduleTable.schRemark1] && mMap[ScheduleTable.schRemark5] != null && mMap[ScheduleTable.schRemark5]!!.isNotEmpty()) {
                comename_tv.text = "To:${mMap[ScheduleTable.schRemark5]}"
                comename_tv.visibility = View.VISIBLE
            }
        } else if (getItemViewType(position) == 0) {
            val holder = holder as HeaderHolder

            val recyclerView = holder.itemView.recyclerView_header
//            var open_daibai = holder.itemView.open_daibai
//            val daiban_sum = holder.itemView.daiban_sum
            val daiban_add = holder.itemView.daiban_add
//            val line2 = holder.itemView.line2

            var count = sharedPrefUtil!!.getString(context, ShareFile.USERFILE, ShareFile.DBCOUNT_SHOW, "4").toInt()

//            if (unlist.size == 0 || count == 0 || unlist.size <= count) {
//                open_daibai.text = ""
//                val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT)
//                open_daibai.layoutParams = params
//                line2.visibility = View.GONE
//            } else {
//                open_daibai.text = "点击展开"
//                val params = LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, Utils.dipTopx(context, 40.0f))
//                open_daibai.layoutParams = params
//                line2.visibility = View.VISIBLE
//            }

//            daiban_sum.text = "待办(${unlist.size})"

            val customLinearLayoutManager = CustomLinearLayoutManager(context)
            customLinearLayoutManager.setScrollEnabled(false)
            recyclerView.layoutManager = customLinearLayoutManager
            recyclerView.itemAnimator = DefaultItemAnimator()

            var newunlist = ArrayList<MutableMap<String, String>>()

            if (unlist.size >= count) {
                unlist.forEach {
                    newunlist.add(it)
                }
//                for (i in 0..count - 1) {
//                    newunlist.add(unlist[i])
//                }
            }

            schHeaderViewAdapter = SchHeaderViewAdapter(context, if (unlist.size >= count) newunlist else unlist, handler, uncount, localpath)
            recyclerView.adapter = schHeaderViewAdapter
            schHeaderViewAdapter.notifyDataSetChanged()

//            open_daibai.setOnClickListener {
//                var schHeaderViewAdapter = SchHeaderViewAdapter(context, unlist , handler, uncount, localpath)
//
//                if (open_daibai.text.toString() == "点击展开") {
//                    SchHeaderViewAdapter(context, unlist , handler, uncount, localpath)
//                    open_daibai.text = "点击收拢"
//                } else if (open_daibai.text.toString() == "点击收拢") {
//                    setOnclick(0, unlist[0], 8, 0)
//                    open_daibai.text = "点击展开"
//                }
//
//                recyclerView.adapter = schHeaderViewAdapter
//                schHeaderViewAdapter.notifyDataSetChanged()
//            }

            daiban_add.setOnClickListener {
                sharedPrefUtil!!.putBoolean(ShareFile.ISHUN, true).commit()
                val dialog = CalenderAddDContentDialog(context, R.style.dialog_translucent, windowManager)
                dialog.show()
                dialog.callBack = object : CalenderAddDContentDialog.CallBack {
                    override fun save() {
                        val m = Message()
                        m.what = 8
                        handler.sendMessage(m)
                    }

                    override fun full(content: String) {
                        val intent = Intent(context, CalenderNoteEditActivity::class.java)
                        intent.putExtra("newadd", true)
                        intent.putExtra("newopeartType", 0)
                        intent.putExtra("content", content)
                        context.startActivity(intent)
                    }
                }
            }

        }
    }

    private var colorss = intArrayOf(R.color.white, R.color.color_m_1, R.color.color_m_2, R.color.color_m_3, R.color.color_m_4, R.color.color_m_5)

    fun nums(stylee: Int, list: List<CalenderNoteBean.PageBean.ItemsBean>): String {
        var tick1 = 0
        var tick2 = 0
        for (listBean in list) {
            if (listBean.endstate == 1) {
                tick1 += 1
            }
            if (listBean.endstate == 2) {
                tick2 += 1
            }
        }
        val title_new = if (stylee == 0) {
            if (list.isEmpty()) {
                "0"
            } else {
                tick1.toString() + "/" + list.size
            }
        } else if (stylee == 4) {
            if (list.isEmpty()) {
                "0"
            } else {
                tick1.toString() + "/" + tick2 + "/" + list.size
            }
        } else {
            list.size.toString() + ""
        }

        return title_new
    }

    internal var color = "0"
    internal fun setBGcolor(linearLayout: LinearLayout, type: String) {
        when (type) {
            "1" -> linearLayout.background = context.resources.getDrawable(R.drawable.repeat_bg_color1)
            "2" -> linearLayout.background = context.resources.getDrawable(R.drawable.repeat_bg_color2)
            "3" -> linearLayout.background = context.resources.getDrawable(R.drawable.repeat_bg_color3)
            "4" -> linearLayout.background = context.resources.getDrawable(R.drawable.repeat_bg_color4)
            "0" -> linearLayout.background = context.resources.getDrawable(R.drawable.repeat_bg_color1)
        }
    }

    public lateinit var schHeaderViewAdapter: SchHeaderViewAdapter


}
